
GOPATH:=$(shell go env GOPATH)

.PHONY: docker-run
docker-run:
	make docker-build
	cd docker && docker-compose build 
	cd docker && docker-compose up -d
	# 删除悬空镜像
	# docker image prune

.PHONY: docker-build
docker-build:
	cd web/ && make swag

	cd services/srv-ProgramDownload/ && make docker-build
	cd services/srv-ProgramLatest/ && make docker-build
	cd services/srv-ProgramList/ && make docker-build
	cd services/srv-ProgramRollback/ && make docker-build
	cd services/srv-ProgramUpload/ && make docker-build

	cd services/srv-UserLogin/ && make docker-build
	cd services/srv-UserLogout/ && make docker-build
	cd services/srv-UserRefreshToken/ && make docker-build
	cd services/srv-UserRegister/ && make docker-build

	cd web/ && make docker-build

.PHONY: docker-delete
docker-delete:
	docker rmi srv-program-download
	docker rmi srv-program-latest
	docker rmi srv-program-list
	docker rmi srv-program-rollback
	docker rmi srv-program-upload

	docker rmi srv-user-login
	docker rmi srv-user-logout
	docker rmi srv-user-refresh-token
	docker rmi srv-user-register
	docker rmi web

.PHONY: docker-down
docker-down:
	cd docker && docker-compose down
	make docker-delete

.PHONY: docker-update
docker-update:
	make docker-down
	make docker-run

.PHONY: git
git:
	# 上传删除生成的包
	rm -rf web/web
	rm -rf services/srv-ProgramDownload/ProgramDownload
	rm -rf services/srv-ProgramLatest/ProgramLatest
	rm -rf services/srv-ProgramList/ProgramList
	rm -rf services/srv-ProgramRollback/ProgramRollback
	rm -rf services/srv-ProgramUpload/ProgramUpload

	rm -rf services/srv-UserLogin/UserLogin
	rm -rf services/srv-UserLogout/UserLogout
	rm -rf services/srv-UserRefreshToken/UserRefreshToken
	rm -rf services/srv-UserRegister/UserRegister
	rm -rf web/web
	git add -A && git commit -m 'xc' && git push origin master
